package kku.cs.hero;

import org.newdawn.slick.Color;

import kku.cs.fgl.GamePane;
import kku.cs.fgl.Scene;
import kku.cs.fgl.SpriteManager;
import kku.cs.fgl.SpriteSheet;
import kku.cs.fgl.actor.BackgroundActor;
import kku.cs.fgl.actor.ImageActor;

public class Scene1 extends Scene {

	public Scene1(int id, GamePane gamePane) {
		super(id, gamePane);
	}

	public Scene1(int id) {
		super(id);
	}

	@Override
	public void enter() {

	}

	@Override
	public void init() {

		getDefView().setBounds(0, 0, 2000, 2000);
		BackgroundActor bg = new BackgroundActor("resource/grass.png");
		bg.setWidth(2020);
		bg.setHeight(2020);
		//add(bg, 0);
//		int map[][]={
//			{-1,-1,1,-1,1,2,-1,3,3,4,1,1,1,0,5,6,5,5,7},		
//			{-1,1,-1,-1,1,2,-1,-1,3,11,-1,-1,-1,0,5,6,5,5,7},		
//			{-1,1,3,-1,1,2,-1,3,7,10,1,1,1,0,5,6,5,5,-1},		
//			{-1,1,3,-1,1,2,-1,4,5,10,1,1,1,0,5,6,5,-1,-1},		
//			{-1,1,3,-1,1,2,-1,3,15,10,1,1,1,0,5,6,5,-1,-1},		
//			{-1, 1, 3,-1, 1,7, 7, 7, 7,7,-1,-1,1,0,5,6,5,-1,-1},		
//			{-1,-1,-1,-1,-1,7,-1,-1,-1,7,-1,-1,-1,-1,-1,-1,-1,-1,-1},		
//			{-1,-1,-1,-1,-1,7,-1,-1,-1,7,-1,-1,-1,-1,-1,-1,-1,-1,-1},		
//			{-1,-1,-1,-1,-1,7, 7, 7, 7,7,-1,-1,-1,-1,-1,-1,-1,-1,-1},		
//			{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}		
//		};
		SpriteSheet mapSheet=new SpriteSheet("resource/map1.gif",32,32);
		int map[][]={
		  {0,0,0,0,0,0,0,2,2,0},		
		  {0,1,1,1,0,0,0,0,0,0},		
		  {0,0,0,0,0,0,0,0,0,0},		
		  {0,0,6,6,0,0,0,0,0,0},		
		  {0,0,6,7,7,7,7,0,0,0},		
		  {0,0,6,6,0,0,0,0,0,0},		
		  {0,0,0,0,0,0,0,9,0,0},		
		  {0,0,5,5,0,0,3,4,0,0},		
		  {0,0,0,0,0,0,0,0,0,0},		
		  {0,0,0,0,0,0,0,0,0,0}};
		TileMapActor tilemap = new TileMapActor(mapSheet, map); 
		add(tilemap,0);
		
/*		for (int i = 0; i < 50; i++) {
			ImageActor tree = new ImageActor("resource/tree.png");
			int x = (int) (Math.random() * 2000);
			int y = (int) (Math.random() * 2000);
			tree.setLocation(x, y);
			add(tree, 1);
			tree.setZorder(y + tree.getHeight());
		}

		SpriteSheet heroSheet, babySheet, girlSheet;
		SpriteManager spritesMan;

		heroSheet = new SpriteSheet("resource/hero1.png", 128 / 4, 192 / 4);
		babySheet = new SpriteSheet("resource/baby.png", 128 / 4, 128 / 4);
		girlSheet = new SpriteSheet("resource/girl.png", 128 / 4, 192 / 4);

		spritesMan = new SpriteManager();
		spritesMan.add("hero.down", heroSheet, "0,1,2,3");
		spritesMan.add("hero.left", heroSheet, "4,5,6,7");
		spritesMan.add("hero.right", heroSheet, "8,9,10,11");
		spritesMan.add("hero.up", heroSheet, "12,13,14,15");
		spritesMan.add("baby.down", babySheet, "0,1,2,3");
		spritesMan.add("baby.left", babySheet, "4,5,6,7");
		spritesMan.add("baby.right", babySheet, "8,9,10,11");
		spritesMan.add("baby.up", babySheet, "12,13,14,15");
		spritesMan.add("girl.down", girlSheet, "0,1,2,3");
		spritesMan.add("girl.left", girlSheet, "4,5,6,7");
		spritesMan.add("girl.right", girlSheet, "8,9,10,11");
		spritesMan.add("girl.up", girlSheet, "12,13,14,15");

		PlayerActor player = new PlayerActor(spritesMan, "hero");
		player.setLocation(200,200);
		add(player,2);
		
		for (int i = 0; i < 50; i++) {
			AutoManActor a = new AutoManActor(spritesMan, "baby");
			int x = (int) (Math.random() * 2000);
			int y = (int) (Math.random() * 2000);
			a.setLocation(x, y);
			add(a, 3);
		}
		for (int i = 0; i < 50; i++) {
			AutoManActor a = new AutoManActor(spritesMan, "girl");
			int x = (int) (Math.random() * 2000);
			int y = (int) (Math.random() * 2000);
			a.setLocation(x, y);
			a.setPower((int)(Math.random()*100));
			add(a, 3);
		}
	*/	
	}

	@Override
	public void leave() {

	}
}
